const Mock = require('mockjs')
var Random = Mock.Random
//定义数据
const data = Mock.mock({
    
})

Mock.mock('/api/login','post',function(option){
    let opt=JSON.parse(option.body);
    let msg;
    //根据传过来的对象，判断data数据中自定义的用户数据是否匹配来更改msg，让msg为对应用户对象
    msg=data.find(item=>item.userName==opt.userName&&item.password==opt.password)

    if(msg){
       return {
        code:200,
        data:msg,
        message:'success'
       }
    }else{
        return {
            code:500,
            data:"请求失败",
            message:'error'
        }
    }
})